package edu.neumont.entities;

import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.util.Scanner;

public class Network{
	private int port;
	private Socket socket;
	private String ipAddress;
	private final String LOCALHOST = "192.168.1.101";
	public Network(){}
	
	public void setUp(String ipAddress, int port){
		this.ipAddress = ipAddress;
		this.port = port;
	}
	public Socket getSocket(){return socket;}

	public boolean connect(boolean useLocalhost){
		if(useLocalhost)
			ipAddress = LOCALHOST;
		try{
			socket = new Socket();
			socket.connect(new InetSocketAddress(ipAddress, port), 2000);
			return true;
		}catch(Exception ex){return false;}
	}
	
	public String getIp(){return ipAddress;}
	public int getPort(){return port;}

	public void setIp(String ip){
		this.ipAddress = ip;
	}
	
}
